#ifndef VLCKITS_H
#define VLCKITS_H

#include <QObject>
#include <vlc/vlc.h>

class VLCKits : public QObject
{
    Q_OBJECT
public:
    explicit VLCKits(QObject *parent = nullptr);
    ~VLCKits();

    bool initVLC();
    bool play(const QString &name, void *hwnd);
    bool playURL(const QString &name, void *hwnd);
    void play();
    void pause();
    void stop();
    void setVolume(int value);
    void setPosition(int value);

    libvlc_media_player_t *getMediaPlayerPtr() const;
    libvlc_time_t getTotalSec() const;

    // 需要修改UI界面的显示时，调用以下三个函数来触发信号
    void setTimeSlidePos(int value);
    void setTimeText(const QString &str);
    void setVolumeSlidePos(int value);

signals:
    void sigTimeSlidePos(int value);
    void sigTimeText(const QString &str);
    void sigVolumeSildePos(int value);

private:
    libvlc_instance_t *_pInstance = nullptr;
    libvlc_media_t *_pMedia = nullptr;
    libvlc_media_player_t *_pMediaPlayer = nullptr;
    libvlc_event_manager_t *_pEventManager = nullptr;
    libvlc_time_t _totalSec = 0;
};

#endif // VLCKITS_H
